how to call an existing JAVA/C api or console command in DXL

Hi all,

I am now trying to integrate DOORS with my own application, and there are two questions may need your support.
1.Is it possible to execute a console command such as "dir" in DXL and parse the output of dir into DXL for later usage?
2.If I have a set of existing java/c api, how to call these apis in DXL and leverage the return value in DXL?

thanks
SystemAdmin - Wed Nov 09 21:36:08 EST 2011

Re: how to call an existing JAVA/C api or console command in DXL
OurGuest - Thu Nov 10 06:40:16 EST 2011

Search for following command on this forum: win32SystemWait_

Re: how to call an existing JAVA/C api or console command in DXL
Mathias Mamsch - Thu Nov 10 08:28:32 EST 2011

1. For the executing of command line you can use system, win32SystemWait_ or the attached shell library, which also enables terminating a started application or getting its output (test code in library).

2. Leveraging an existing C API from DXL is impossible without very dirty hacks. Interfacing a Java API? Well maybe in "DOORS Next Generation ...". What you always can do is create a COM server in some language of your choice, which will then interface to your APIs. You can then use the COM server to interface to your applications. This can be done quickly, however you need some experience in COM server programming to "get it right".

Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Attachments

attachment_14702321_Shell.inc

Re: how to call an existing JAVA/C api or console command in DXL
jester76 - Thu Oct 24 20:40:38 EDT 2013

Mathias Mamsch - Thu Nov 10 08:28:32 EST 2011
1. For the executing of command line you can use system, win32SystemWait_ or the attached shell library, which also enables terminating a started application or getting its output (test code in library).

2. Leveraging an existing C API from DXL is impossible without very dirty hacks. Interfacing a Java API? Well maybe in "DOORS Next Generation ...". What you always can do is create a COM server in some language of your choice, which will then interface to your APIs. You can then use the COM server to interface to your applications. This can be done quickly, however you need some experience in COM server programming to "get it right".

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Hello,

It would be neat if the shell/command windows can be hid. 

Thanks

Jester

Re: how to call an existing JAVA/C api or console command in DXL
Mathias Mamsch - Fri Oct 25 06:32:41 EDT 2013

jester76 - Thu Oct 24 20:40:38 EDT 2013

Hello,

It would be neat if the shell/command windows can be hid. 

Thanks

Jester

Please note that there are NO shell windows appearing, when using shell.inc to start Notepad. If there is a shell window appearing when you are using shell.inc to run something it may be, that you are running a console application (that is by itself creating a console to output stuff). The normal OS start process functions do not suppress the console of console applications when you run them. For this you need to start your console application over a separate tool, that will block the console. Details on your favorite search engine, e.g. see here: http://www.codeproject.com/Articles/2537/Running-console-applications-silently

Alternatively if you are running a tool, that you created yourself, just link it as a non console application.

Regards, Mathias

Re: how to call an existing JAVA/C api or console command in DXL
Mathias Mamsch - Fri Oct 25 06:51:26 EDT 2013

Mathias Mamsch - Fri Oct 25 06:32:41 EDT 2013

Please note that there are NO shell windows appearing, when using shell.inc to start Notepad. If there is a shell window appearing when you are using shell.inc to run something it may be, that you are running a console application (that is by itself creating a console to output stuff). The normal OS start process functions do not suppress the console of console applications when you run them. For this you need to start your console application over a separate tool, that will block the console. Details on your favorite search engine, e.g. see here: http://www.codeproject.com/Articles/2537/Running-console-applications-silently

Alternatively if you are running a tool, that you created yourself, just link it as a non console application.

Regards, Mathias

It seems the WScript OLE object also allows you to start an application without a window. So in this case, you have to use the "Run" method instead of the exec method and pass 0 (hide) as a second argument. But in this case you cannot get the output of the process or terminate it, so that is something that cannot be patched in shell.inc. So something like this should get you started:


    OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
    OleAutoObj result = null
    
    OleAutoArgs args = create()
    
    put(args, "CMD /C CD /D C:\\ & DIR /S")
      put(args, 0)
      put(args, true)
    
    print oleMethod(shellObj, "Run", args , result)

Regards, Mathias

Re: how to call an existing JAVA/C api or console command in DXL
EHcnck - Thu Jan 14 08:22:06 EST 2016

Mathias Mamsch - Fri Oct 25 06:51:26 EDT 2013

It seems the WScript OLE object also allows you to start an application without a window. So in this case, you have to use the "Run" method instead of the exec method and pass 0 (hide) as a second argument. But in this case you cannot get the output of the process or terminate it, so that is something that cannot be patched in shell.inc. So something like this should get you started:


    OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
    OleAutoObj result = null
    
    OleAutoArgs args = create()
    
    put(args, "CMD /C CD /D C:\\ & DIR /S")
      put(args, 0)
      put(args, true)
    
    print oleMethod(shellObj, "Run", args , result)

Regards, Mathias

when I run the above code I get the following error any ideas what maybe the cause?:

 

OLE problem: , OLE error code: -2147024891